home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_gen_doorlocked1side.cog < prev    next >
Text File  |  1999-11-15  |  4KB  |  154 lines

  1. # Jones 3D Cog Script
  2. #
  3. # gen_DoorLocked1Side.cog
  4. #
  5. # This script will handle a door that can be opened from
  6. # one side only. Once it has been opened once it will
  7. # open from both sides.
  8. #
  9. # You have to link in the sector into which the player
  10. # is when you want the door to open.
  11. #
  12. # [YB]
  13. #
  14. # 8/28/97 Added clicking sounds [DB]
  15. #
  16. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  17. # ========================================================================================
  18.  
  19. symbols
  20.     message     startup
  21.     message     activate
  22.     message     arrived
  23.     message     blocked
  24.  
  25.     thing       door0                            linkid=0 mask=0x405
  26.     thing       door1                            linkid=1 mask=0x405
  27.     thing       door2                            linkid=2 mask=0x405
  28.     thing       door3                            linkid=3 mask=0x405
  29.  
  30.     flex        movespeed=8.0
  31.     flex        sleeptime=2.0
  32.     sector      correctside
  33.  
  34.     float        lightValueR=0.5
  35.     float        lightValueG=0.5
  36.     float        lightValueB=0.5
  37.  
  38.     vector    vecLightValue        local
  39.  
  40. #    sound       dialogue=i00ky73t.wav
  41. #    sound       wav0=lvrclik2.wav
  42.  
  43.     sector      doorsector                       local
  44.     int         numdoors                         local
  45.     int         doorstatus                       local
  46.     int         movestatus                       local
  47.     int         opened=0                         local
  48.     int         said_locked=0                    local
  49.  
  50. # subroutines
  51. flex    open_doors=0.0    local
  52. flex    close_doors=0.0    local
  53. flex    checkstatus=0.0    local
  54. end
  55.  
  56. # ========================================================================================
  57.  
  58. code
  59.  
  60. startup:
  61.    if (door0 >= 0) numdoors = numdoors + 1;
  62.    if (door1 >= 0) numdoors = numdoors + 1;
  63.    if (door2 >= 0) numdoors = numdoors + 1;
  64.    if (door3 >= 0) numdoors = numdoors + 1;
  65.  
  66.    doorsector = getthingsector(door0);
  67.    sectoradjoins(doorsector, 0);
  68.  
  69.     // add light to door sector
  70.     vecLightValue = VectorSet(lightValueR, lightValueG, lightValueB);
  71.    sectorlight(doorsector, vecLightValue, 0.0);
  72.    return;
  73.  
  74. # ........................................................................................
  75.  
  76. activate:
  77.    if((opened == 1) || (GetThingSector(GetSourceRef()) == correctside))
  78.    {
  79.       call checkstatus;
  80.       if (movestatus) return;
  81.       if (doorstatus == 0)
  82.       {              // all pieces are at frame 0
  83.          sectoradjoins(doorsector, 1);
  84.          call open_doors;
  85.          opened = 1;
  86.          }
  87.    }
  88.    else
  89.    if (said_locked == 0)
  90.       {
  91.       // playsoundlocal(dialogue, 1, 0, 132);
  92.       // jkPrintUNIString(-1, 1001);
  93.       said_locked=1;
  94.       }
  95.       else
  96.       {
  97.       // PlaySoundThing(wav0, door0, 1.0, -1, -1, 0);
  98.       }
  99.  
  100.  
  101.    return;
  102.  
  103. # ........................................................................................
  104.  
  105. arrived:
  106.    call checkstatus;
  107.    if (movestatus) return;
  108.    if (doorstatus == numdoors) {          // all pieces are at frame 1
  109.       sleep(sleeptime);
  110.       call close_doors;
  111.    } else if (doorstatus == 0) {          // all pieces are at frame 0
  112.       sectoradjoins(doorsector, 0);
  113.    }
  114.    return;
  115.  
  116. # ........................................................................................
  117.  
  118. blocked:
  119.    call open_doors;
  120.    return;
  121.  
  122. # ........................................................................................
  123.  
  124. open_doors:
  125.    movetoframe(door0, 1, movespeed);
  126.    if (door1 >= 0) movetoframe(door1, 1, movespeed);
  127.    if (door2 >= 0) movetoframe(door2, 1, movespeed);
  128.    if (door3 >= 0) movetoframe(door3, 1, movespeed);
  129.    return;
  130.  
  131.  
  132. close_doors:
  133.    movetoframe(door0, 0, movespeed);
  134.    if (door1 >= 0) movetoframe(door1, 0, movespeed);
  135.    if (door2 >= 0) movetoframe(door2, 0, movespeed);
  136.    if (door3 >= 0) movetoframe(door3, 0, movespeed);
  137.    return;
  138.  
  139. checkstatus:
  140.    movestatus = ismoving(door0);
  141.    if (door1 >= 0) movestatus = movestatus + ismoving(door1);
  142.    if (door2 >= 0) movestatus = movestatus + ismoving(door2);
  143.    if (door3 >= 0) movestatus = movestatus + ismoving(door3);
  144.  
  145.    doorstatus = getcurframe(door0);
  146.    if (door1 >= 0) doorstatus = doorstatus + getcurframe(door1);
  147.    if (door2 >= 0) doorstatus = doorstatus + getcurframe(door2);
  148.    if (door3 >= 0) doorstatus = doorstatus + getcurframe(door3);
  149.    return;
  150.  
  151.  
  152. end
  153.  
  154.